<!DOCTYPE html>
<html>

<head>

    {include file="Public:header"}
    <style>
        .radio-inline input[type=radio] {
            margin-top: 4px;
        }
    </style>
</head>

<body style="color:#333;padding:3px;">
<!-- 标题 -->
<div class="page-heade">
    <h1 class="title_color">销售物料出库确认</h1>
</div>
<!-- 标题 -->
<div>
    <form action="" class="form-inline">
        <table class="row-margin-top tab-content table-bordered table" border="1" style="margin-bottom:0">
            <tr>
                <td style="min-width: 160px;width: 160px"><label for="">申请人：</label></td>
                <td><a href="javascript:;">{$data.sqr}</a></td>
                <td style="min-width: 160px;width: 160px"><label for="">申请人部门：</label></td>
                <td>{$data.sqrbm}</td>
                <td style="min-width: 160px;width: 160px"><label for="">申请日期：</label></td>
                <td>{$data.sqrq}</td>
            </tr>
            <tr>
                <td style="min-width: 160px;width: 160px"><label for="">确认人：</label></td>
                <td><a href="javascript:;">{$data.qrr}</a></td>
                <td style="min-width: 160px;width: 160px"><label for="">确认人部门：</label></td>
                <td>{$data.qrrbm}</td>
                <td style="min-width: 160px;width: 160px"><label for="">确认日期：</label></td>
                <td>{$data.qrrq}</td>
            </tr>
            <tr>
                <td colspan="6" style="padding: 1px">
                    <table class="table table-bordered" style="margin:0;padding: 0">
                        <tr class="info">
                            <th class="text-center">序号</th>
                            <th class="text-center">经销商</th>
                            <th class="text-center">品牌</th>
                            <th class="text-center">物料编码</th>
                            <th class="text-center">物料名称</th>
                            <th class="text-center">费用科目</th>
                            <th class="text-center">单位</th>
                            <th class="text-center">单价</th>
                            <th class="text-center">申请数量</th>
                            <th class="text-center">已出库数量</th>
                            <th class="text-center">本次出库数量</th>
                            <th class="text-center">体积(立方米)</th>
                            <th class="text-center">重量(吨)</th>
                        </tr>

                        {volist name="data.list" id="row" key="k"}
                        <tr data-dwtj="{$row.tj}" data-dwzl="{$row.zl}">
                            <td>{$k}</td>
                            <td>{$row.jxs}</td>
                            <td>{$row.brand}</td>
                            <td><a href="sell_wl_detail.html">{$row.wlbm}</a></td>
                            <td>{$row.wlmc}</td>
                            <td>{$row.fykm}</td>
                            <td>{$row.unit}</td>
                            <td class="text-right">{$row.dj}</td>
                            <td class="text-right">{$row.sqsl}</td>
                            <td class="text-right">{$row.ycksl}</td>
                            <td><input type="text" class="form-control" name="bccksl[{$row.id}]" value="{$row.bccksl}" ></td>
                            <td class="text-right tj">{$row.tj}</td>
                            <td class="text-right zl">{$row.zl}</td>
                        </tr>
                        {/volist}
                        <tr class="font-bold text-right">
                            <td colspan="8" class="text-right">小计：</td>
                            <td class="text-right">{$data.sqsl_xj}</td>
                            <td class="text-right">{$data.ycksl_xj}</td>
                            <td class="text-right" id="cksl_xj">{$data.ycksl_xj}</td>
                            <td class="text-right" id="tj_xj">{$data.tj_xj}</td>
                            <td class="text-right" id="zl_xj">{$data.zl_xj}</td>
                        </tr>
                    </table>
                </td>
            </tr>
            <tr>
                <td style="min-width: 160px;width: 160px">
                    <label for="" class="form-label">申请单说明：</label>
                </td>
                <td colspan="5">{$data.brief}</td>
            </tr>
        </table>
        <div class="padding-10 text-center">
            <button class="btn btn-info sh" type="button" id="bfck">部分出库</button>
            <button class="btn btn-success sh" type="button" id="ckwb">出库完毕</button>
            <button class="btn btn-warning sh" type="button" onclick="back()" id="fh">返回</button>
        </div>
        <p class="padding-10">
            <label for="items">
                <span class="lr_5"></span><input type="checkbox" name="items" id="items"><span class="lr_5"></span><span
                    class="trTotal2 font-bold">剩余部分不再出库，设置本单为出库已完毕</span><span class="font-bold colorRed">（注意：如果选择剩余部分不再出库，则本单所有未出库部分都不再出库，同时本次操作也不做任何出库处理。）</span>
            </label>
        </p>
        <div id="qrck_box" style="display: none;">
            <table class="table table-bordered">
                <tr class="info">
                    <th>设置原因为<font color="red">*</font>:</th>
                </tr>
                <tr>
                    <td>
                        <input type="text" name="qtyy" size="100%">
                    </td>
                </tr>
                <tr>
                    <td class="text-center">
                        <button class="btn btn-info" type="button" id="szwckywb">设置为出库已完毕</button>
                        <button class="btn btn-success" type="button" id="qxsz">取消设置</button>
                    </td>
                </tr>
            </table>
        </div>
    </form>
</div>
<!-- 全局js -->
{include file="Public:footer"}
<!-- <script src="js/plugins/metisMenu/jquery.metisMenu.js"></script> -->
<script src="__STATIC__/layout/js/plugins/slimscroll/jquery.slimscroll.min.js"></script>
<script src="__STATIC__/layout/js/common.js"></script>
<script>
    $(document).ready(function () {

        /**
         * 部分出库
         */
        $('#bfck').on('click',function () {
            var param = $(this).closest('form').serialize()
            param += '&bfck=1'
            $.post('',param,function (data) {
                if(data.success){
                    swal({title:data.msg},function () {
                        location.href='{:url("xswlfhqr")}'
                    })
                }else{
                    swal('',data.msg,'error')
                }
            },'json')
            return false
        })

        /**
         * 出库完毕
         */
        $('#ckwb').on('click',function () {
            var param = {}
            param.bfck = 2
            $.post('',param,function (data) {
                if(data.success){
                    swal({title:data.msg},function () {
                        location.href='{:url("xswlfhqr")}'
                    })
                }else{
                    swal('',data.msg,'error')
                }
            },'json')
            return false
        })

        /**
         * 设置为出库已完毕
         */
        $('#szwckywb').on('click',function () {
            var param = $(this).closest('form').serialize()
            param += '&bfck=1&qrck=1'
            $.post('',param,function (data) {
                if(data.success){
                    swal({title:data.msg},function () {
                        location.href='{:url("xswlfhqr")}'
                    })
                }else{
                    swal('',data.msg,'error')
                }
            },'json')
            return false
        })

        var $ObjectNum = $(".ObjectNum");
        toNum($ObjectNum);

        //取消设置
        $('#qxsz').on('click',function () {
            $('#qrck_box').hide()
            $('#items').prop('checked',false)
            $('#bfck,#ckwb,#fh').prop('disabled',false)
        })

        //剩余部分不再出库
        $('#items').on('click',function () {
            if($(this).prop('checked')){
                $('#qrck_box').show()
                $('.sh').prop('disabled',true)
            }else{
                $('#qrck_box').hide()
                $('.sh').prop('disabled',false)
            }
        })

        //输入数量
        $('input[name^=bccksl]').on('input',function () {
            var hj = 0;
            $('[name^=bccksl]').each(function (i,o) {
                hj += parseInt($(o).val()?$(o).val():0)
            })
            $('#cksl_xj').html(hj)

            //获取单位体积和重量
            var dwtj = $(this).closest('tr').data('dwtj')
            var dwzl = $(this).closest('tr').data('dwzl')
            var num = $(this).val()?$(this).val():0
            var tj = parseFloat(num)*parseFloat(dwtj?dwtj:0)
            var zl = parseFloat(num)*parseFloat(dwzl?dwzl:0)
            $(this).closest('td').next('td').html(tj)
            $(this).closest('td').next('td').next('td').html(zl)

            var hj = 0;
            $('.tj').each(function (i,o) {
                hj += parseInt($(o).html()?$(o).html():0)
            })
            $('#tj_xj').html(hj)
            var hj = 0;
            $('.zl').each(function (i,o) {
                hj += parseInt($(o).html()?$(o).html():0)
            })
            $('#zl_xj').html(hj)
        })
    })
</script>
</body>

</html>
